package com.atguigu.ai.repository;

import com.atguigu.ai.constants.ChatTypeEnum;
import org.springframework.stereotype.Component;

import java.util.HashSet;
import java.util.Set;

@Component
public class InMemoryChatHistoryRepository implements ChatHistoryRepository {

    private final Set<String> chatHistory = new HashSet<>();
    private final Set<String> serviceHistory = new HashSet<>();
    private final Set<String> pdfHistory = new HashSet<>();

    @Override
    public void save(String type, String chatId) {
        if (ChatTypeEnum.chat.getValue().equals(type)) {
            chatHistory.add(chatId);
        } else if (ChatTypeEnum.service.getValue().equals(type)) {
            serviceHistory.add(chatId);
        } else if (ChatTypeEnum.pdf.getValue().equals(type)) {
            pdfHistory.add(chatId);
        }
    }

    @Override
    public Set<String> getChatHistory(String type) {
        if (ChatTypeEnum.chat.getValue().equals(type)) {
            return chatHistory;
        } else if (ChatTypeEnum.service.getValue().equals(type)) {
            return serviceHistory;
        } else if (ChatTypeEnum.pdf.getValue().equals(type)) {
            return pdfHistory;
        }
        return null;
    }
}
